import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:lx_widgets_library/lx_widgets_library.dart';

import '../../../../l10n/local.dart';
import '../../../others/custom_view/setting_items/settting_section.dart';
import 'controller.dart';

class AccountSecurityView extends BaseGetView<AccountSecurityController> {
  AccountSecurityView({super.key});

  @override
  String get title => local.account_security;

  @override
  Widget buildBody(BuildContext context) {
    return Material(
      color: Colors.black,
      child: Stack(
        children: [
          Obx(
            () {
              final itemList = controller.state.itemList;
              return ListView.builder(
                itemCount: itemList.length,
                itemBuilder: (context, sectionIndex) {
                  final section = itemList[sectionIndex];
                  return SettingSection(
                    title: section.sectionType.name,
                    children: section.subItems,
                  );
                },
              );
            },
          ),
          Positioned(
            bottom: tabBarSpace + 2 * CONTENT_MARGIN,
            left: CONTENT_MARGIN * 2,
            right: CONTENT_MARGIN * 2,
            child: LxButton(
              height: 44.w,
              borderRadius: BorderRadius.circular(20.w),
              title: context.s.log_out,
              buttonTypeCustomColor: ButtonTypeColor()
                ..backgroundColor = GrayColor.gray2.withOpacity(0.5)
                ..borderColor = Colors.transparent
                ..textColor = Colors.white.withOpacity(0.8),
              onTap: () {
                controller.logoutOnTap();
              },
            ),
          )
        ],
      ),
    );
  }
}
